<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='xxlb'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">



            <div class="layui-form-item">
                <form name="totalForm" id="totalForm">

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='ptlx'/></label>
                        <div class="layui-input-inline">
                            <select name="platformType">
                                <option value="0" <c:if test="${params.platformType == 0}">selected</c:if>><fmt:message key='scd'/></option>
                                <option value="1" <c:if test="${params.platformType == 1}">selected</c:if>><fmt:message key='cgd'/></option>
                            </select>
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='xxbt'/></label>
                        <div class="layui-input-inline">
                            <input type="text" name="title" value="${params.title}" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='zt'/></label>
                        <div class="layui-input-inline">
                            <select name="status">
                                <option value="0" <c:if test="${params.status == 0}">selected</c:if>><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${params.status == 1}">selected</c:if>><fmt:message key='dfs'/></option>
                                <option value="2" <c:if test="${params.status == 2}">selected</c:if>><fmt:message key='yfs'/></option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                    </div>
                </form>
            </div>
        </div>

    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">
            <shiro:hasPermission name="message:create">
                <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-normal" id="add"><i class="layui-icon">&#xe61f;</i> <fmt:message key='xzxx'/></a>
            </shiro:hasPermission>

            <table class="layui-table" lay-size="sm">
                <thead>
                <th width="5%"><fmt:message key='xh'/></th>
                <th width="20%"><fmt:message key='xxbt'/></th>
                <th width="30%"><fmt:message key='zy'/></th>
                <th><fmt:message key='fssj'/></th>
                <th><fmt:message key='zt'/></th>
                <th><fmt:message key='cz'/></th>
                </thead>
                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td>${status.index + 1}</td>
                        <td>${item.title}</td>
                        <td>${item.digest}</td>
                        <td>
                            <c:if test="${item.status == 1}"> - </c:if>
                            <c:if test="${item.status == 2}"> <fmt:formatDate value="${item.sendTime}" type="both"/> </c:if>
                        </td>
                        <td>
                            <c:if test="${item.status == 1}"><b style="color: #f00;"><fmt:message key='dfs'/></b></c:if>
                            <c:if test="${item.status == 2}"><b style="color: green;"><fmt:message key='yfs'/></b></c:if>
                        </td>
                        <td>
                            <div class="layui-btn-container">
                                <c:choose>
                                    <c:when test="${item.status == 2}">
                                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-detail"><fmt:message key='ck'/></a>
                                    </c:when>
                                    <c:otherwise>
                                        <shiro:hasPermission name="message:send">
                                            <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-send"><fmt:message key='fs'/></a>
                                        </shiro:hasPermission>
                                        <shiro:hasPermission name="message:modify">
                                            <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-modify"><fmt:message key='bj'/></a>
                                        </shiro:hasPermission>
                                    </c:otherwise>
                                </c:choose>
                                <shiro:hasPermission name="message:remove">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs feijin-remove"><fmt:message key='sc'/></a>
                                </shiro:hasPermission>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>

    layui.use("layer", function () {

        //添加
        $("#add").click(function () {
            layer.open({
                type: 2,
                title: "<fmt:message key='xzxtxx'/>",
                content: "${web_domain}/mall/message/create",
                area: ["90%", "90%"],
                btn: ["<fmt:message key='qd'/>", "<fmt:message key='qx'/>"],
                yes: function (index, layero) {
                    layero.find('iframe').contents().find("#submit").click();
                }
            });
        });

        //编辑
        $(".feijin-modify").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2,
                content: "${web_domain}/mall/message/modify?id=" + id,
                area: ["90%", "90%"],
                btn: ["<fmt:message key='qd'/>", "<fmt:message key='qx'/>"],
                yes: function (index, layero) {
                    layero.find('iframe').contents().find("#submit").click();
                }
            });
        });


        //查看
        $(".feijin-detail").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                title: "<fmt:message key='xxxq'/>",
                type: 2,
                content: "${web_domain}/mall/message/modify?id=" + id,
                area: ["90%", "90%"]
            });
        });

        //上架
        $(".feijin-send").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrm?xxfs'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/message/send",
                    data: {id: id}
                });
            });
        });


        //删除
        $(".feijin-remove").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrscm?'/>", function () {
                feijin.delete({
                    url: "${web_domain}/mall/message/remove",
                    data: {"id": id}
                });
            });
        });

    });
</script>
</body>
</fmt:bundle>
</html>
